# f = open('day04文件操作\\a.txt', 'r', encoding='utf-8')
# lst = []

'''
通过代码，将其构建成这种数据类型：[{'name': 'apple', 'price': '10', 'amount': '3'}, .....]，并计算出总价格.
'''
# for i in f:
#     a, b, c = i.split()
#     dic = {}
#     dic["name"] = a
#     dic["price"] = b
#     dic["amount"] = c
#     lst.append(dic)
# print(lst)

f = open('day04文件操作\\a.txt', 'r', encoding='utf-8')
lst = []

for i in f:
    a, b, c = i.split()
    dic = {"name": a, "price": b, "amount": c, "tcost": int(b)*int(c)}
    lst.append(dic)
print(lst)
# 不一定需要以下代码
# count = 0
# for i in lst:
#     # print(i["tcost"])
#     count+=int(i["tcost"])
# print(count)
